package com.wude.guild.adapter;

import android.app.Activity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.wude.bean.AddressBean;
import com.wude.guild.fragment.ShouHuoFragment;
import com.wude.guild.holder.AddressHolder;

import java.util.ArrayList;
import java.util.List;

/**
 * 收货地址Adapter
 * Created by Administrator on 2017/3/21.
 */

public class AddresAdapter extends BaseAdapter {
    private final Activity con;
    public List<AddressBean> list = new ArrayList<AddressBean>();
    private ShouHuoFragment fragment;

    public AddresAdapter(Activity activity, ShouHuoFragment fragment) {
        this.con = activity;
        this.fragment = fragment;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        AddressHolder holder = null;

        if (convertView == null) {
            holder = new AddressHolder(fragment);
        } else {
            holder = (AddressHolder) convertView.getTag();
        }
        AddressBean addressBean = list.get(position);
        holder.setData(addressBean, position, con);
        return holder.getContentView();
    }

    public void setList(List<AddressBean> b) {
        this.list = b;
        notifyDataSetChanged();
    }

    public List<AddressBean> getList() {
        return list;
    }
}
